package com.example.demo.mapper;

import com.example.demo.entity.Middle;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author
 * @Description
 */
@Mapper
public interface MiddleMapper {
    @Select("SELECT * FROM middle WHERE user_id = #{userId}")
    @Results(id = "middle", value = {
            @Result(id = true, property = "id", column = "id"),
            @Result(property = "userId", column = "user_id"),
            @Result(property = "groupId", column = "group_id")
    })
    List<Middle> findMiddleListByUserId(Integer userId);

    @Insert("INSERT INTO middle (id, group_id, user_id)" +
            "VALUES (#{id}, #{groupId}, #{userId})")
    Long add(Middle middle);
}
